<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

namespace App\Controller\admin;

use App\Model\Admin\Job;
use Hyperf\HttpServer\Annotation\AutoController;
use Psr\Http\Message\ResponseInterface;
use Hyperf\DbConnection\Model\Model;
/**
 * 定时任务调度.
 */
#[AutoController]
class JobController extends Crud
{
    /**
     * @var Job
     */
    protected Model $model;

    /**
     * 构造函数.
     */
    public function __construct()
    {
        $this->model = new Job();
        parent::__construct();
    }

    /**
     * 浏览.
     */
    public function index(): ResponseInterface
    {
        $render = $this->render;
        return $render->render('job/index');
    }

    /**
     * 插入.
     */
    public function insert(): ResponseInterface
    {
        $request = $this->request;
        $render = $this->render;
        if ($request->isMethod('post')) {
            return parent::insert($request);
        }
        return $render->render('job/insert');
    }

    /**
     * 更新.
     */
    public function update(): ResponseInterface
    {
        $request = $this->request;
        $render = $this->render;
        if ($request->isMethod('post')) {
            return parent::update($request);
        }
        return $render->render('job/update');
    }
}
